package MallSecret

import (
	CoreSQL "gitee.com/fotomxq/weeekj_core/v5/core/sql"
	Router2SystemConfig "gitee.com/fotomxq/weeekj_core/v5/router2/system_config"
)

type ArgsCreateSecond struct {
	//商品id
	ProductID int64 `db:"product_id" json:"productID"`
	//商品名称
	ProductName string `db:"product_name" json:"productName"`
	//秒杀价格
	Price int64 `db:"price" json:"price"`
	//组织机构
	OrgID int64 `db:"org_id" json:"orgId"`
	//秒杀开始时间
	StartTime string `db:"start_time" json:"startTime"`
	//秒杀结束时间
	EndTime string `db:"end_time" json:"endTime"`
	//秒杀日期
	SecondDate string `db:"second_date" json:"secondDate"`
}

// CreateStatistics 创建秒杀商品
func CreateStatistics(args *ArgsCreateSecond) (errCode string, err error) {
	//创建数据
	_, err = CoreSQL.CreateOne(Router2SystemConfig.MainDB.DB,
		"INSERT INTO mall_second (product_id,price,status,org_id,product_name,start_time,end_time,second_date) VALUES (:product_id,:price,:status,:org_id,:product_name,:start_time,:end_time,:second_date)", map[string]interface{}{
			"product_id":   args.ProductID,
			"product_name": args.ProductName,
			"price":        args.Price,
			"status":       0,
			"org_id":       args.OrgID,
			"start_time":   args.StartTime,
			"end_time":     args.EndTime,
			"second_date":  args.SecondDate,
		})
	if err != nil {
		errCode = "insert"
		return
	}
	//反馈
	return
}
